<template>
</template>

<script setup>
  import { ref, onMounted } from "vue"
  import axios from "axios"
  import { useRoute, useRouter } from "vue-router";
  import http from "../http"

  const route = useRoute()
  const router = useRouter()

  let admin = ref({})

  admin.value.name = prompt("请输入用户名")
  admin.value.password = prompt("请输入密码")

  onMounted(() => {
    http.post(`myadmin/login/`, admin.value)
    .then(res=>{
      console.log(res)
      localStorage.setItem("token", res.data.token)
      localStorage.setItem("url_list", JSON.stringify(res.data.url_list))
      localStorage.setItem("pid_list", JSON.stringify(res.data.pid_list))
      // router.push({path: "/admin", query: {role: res.data.admin.role}})
      router.push({path: "/admin"})
    })
  })

</script>